var request = require('../../utils/httpUtils.js');

/**
 * 获取订单详情接口
 */
function getOrderDetailsData(param, successCall) {
  request.Get(true, request.api.order_details, param,
    function (success) {
      if (success) {
        successCall(success)
      }
    },
    function (error) {
      wx.showToast({
        title: error.msg,
        icon: 'none',
        duration: 2000,
      })
    })
}

/**
 * 确认发货
 */
function comfireSendGoods(param, successCall) {
  request.Post(false, request.api.comfire_send_goods, param,
    function (success) {
      successCall(success)
    },
    function (error) {
      wx.showToast({
        title: error.msg,
        icon: 'none',
        duration: 2000,
      })
    })
}

/**
 * 收人收货
 */
function coolectGoods(param, successCall) {
  request.Post(false, request.api.collect_goods, param,
    function (success) {
      successCall(success)
    },
    function (error) {
      wx.showToast({
        title: error.msg,
        icon: 'none',
        duration: 2000,
      })
    })
}

/**
 * 微信预支付
 */
function prePay(param, successCall) {
  request.Post(false, request.api.pre_pay, param,
    function (success) {
      successCall(success)
    },
    function (error) {
      wx.showToast({
        title: error.msg,
        icon: 'none',
        duration: 2000,
      })
    })
}

/**
 * 修改订单
 */
function upOrdetails(param, successCall) {
  request.Post(false, request.api.up_ordetails, param,
    function (success) {
      successCall(success)
    },
    function (error) {
      wx.showToast({
        title: error.msg,
        icon: 'none',
        duration: 2000,
      })
    })
}

exports.upOrdetails = upOrdetails;
exports.prePay = prePay;
exports.getOrderDetailsData = getOrderDetailsData;
exports.comfireSendGoods = comfireSendGoods;
exports.coolectGoods = coolectGoods;